package client.comm.baoding.adapter

import androidx.recyclerview.widget.DiffUtil
import client.comm.baoding.R
import client.comm.baoding.api.bean.HangOrderRecord
import client.comm.baoding.databinding.LayoutItemMyGuadanBinding
import client.comm.commlib.base.BasePagingAdapter
import client.comm.commlib.base.PagingViewHoder

class PagingMyGuaDAdapter :
    BasePagingAdapter<HangOrderRecord.Order>(object :
        DiffUtil.ItemCallback<HangOrderRecord.Order>() {
        override fun areItemsTheSame(
            oldItem: HangOrderRecord.Order,
            newItem: HangOrderRecord.Order
        ): Boolean {
            return false
        }

        override fun areContentsTheSame(
            oldItem: HangOrderRecord.Order,
            newItem: HangOrderRecord.Order
        ): Boolean {
            return oldItem == newItem
        }
    }) {

    override fun bindItem(holder: PagingViewHoder, t: Any) {
        val binding = holder.binding as LayoutItemMyGuadanBinding
        val bean = t as HangOrderRecord.Order
        binding.bean = bean

//        when (bean.r_type) {
//            1 -> binding.typeTxt = "挂单服务中心"
//            2 -> binding.typeTxt = "挂单供应商"
//        }

//        when (bean.status) {
//            0 -> {
//                binding.status = "挂单中"
//            }
//            1 -> {
//                binding.status = "全部成交"
//            }
//            2 -> {
//                binding.status = "手动撤销"
//            }
//            3 -> {
//                binding.status = "系统撤销"
//            }
//        }

        val time = bean.create_time.substring(5, bean.create_time.length - 3)
        binding.time = time
    }

    override fun getItemLayout(): Int {
        return R.layout.layout_item_my_guadan
    }
}